package com.unytech.watersoil.entity.security;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.unytech.watersoil.common.GlobalEnum;
import com.unytech.watersoil.entity.BaseObject;

/**
 * 权限实体类
 * @author LONG
 *
 */
@Entity @Table(name="T_PERMISSION")
public class Permission extends BaseObject implements Serializable {
	@Id @Column(length=12,nullable=false,unique=true)
	private String permid;
	
	@Column(length=32,nullable=false,unique=true)
	private String permName;
//	private Integer permDepth;
	@Column(length=12,nullable=false)
	private String parentId;
	
	@Column(length=50,nullable=false)
	private String permURL;
	
	//权限类型，accordion:左侧主菜单权限，tab:选项卡权限，button:按钮权限
	@Column(length=20,nullable=false)
	private String permType = GlobalEnum.ACCORDION.toString(); 
	
	@Transient
	private Integer permindex;   //权限排序索引
	
	@Transient
	private Set<Permission> subPerms;
	
	@ManyToMany(cascade=CascadeType.REFRESH,mappedBy="permissions")
	private Set<PermissionGroup> permGroup;  //与权限组之间的多对多关系映射
	
	public String getPermid() {
		return permid;
	}
	public void setPermid(String permid) {
		this.permid = permid;
	}
	public String getPermName() {
		return permName;
	}
	public void setPermName(String permName) {
		this.permName = permName;
	}
//	public Integer getPermDepth() {
//		return permDepth;
//	}
//	public void setPermDepth(Integer permDepth) {
//		this.permDepth = permDepth;
//	}
	public String getParentId() {
		return parentId;
	}
	public void setParentId(String parentId) {
		this.parentId = parentId;
	}
	public String getPermURL() {
		return permURL;
	}
	public void setPermURL(String permURL) {
		this.permURL = permURL;
	}
	public void setPermType(String permType) {
		this.permType = permType;
	}
	public String getPermType() {
		return permType;
	}	
	public Integer getPermindex() {
		return permindex;
	}
	public void setPermindex(Integer permindex) {
		this.permindex = permindex;
	}
	public Set<Permission> getSubPerms() {
		return subPerms;
	}
	public void setSubPerms(Set<Permission> subPerms) {
		this.subPerms = subPerms;
	}
	public void setPermGroup(Set<PermissionGroup> permGroup) {
		this.permGroup = permGroup;
	}
	public Set<PermissionGroup> getPermGroup() {
		return permGroup;
	}
}
